import { GACHALEVEL, GACHATIMEGRP } from '../../config/play_def'
import { CommonBuff } from '../../config/role_def';
import util from '../tool/util';

cc.Class({
    extends: cc.Component,

    properties: {
        boxSp: cc.Sprite,
        timeLab: cc.Label,
        box_bg: cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start() {

    },

    // update (dt) {},
    /**
     * 
     * @param {*} index 数组下标
     * @param {*} isGet 是否领取
     * @param {*} isShowLab 是否展示lab
     */
    init(index, isGet, isShowLab) {
        let level = GACHALEVEL[index]
        this.canClick = isGet ? false : true
        let name = this.changeName(level)
        if (isGet) {
            name = name.concat('_op')
        }
        this.box_bg.color = isGet ? cc.Color.BLUE : cc.Color.WHITE
        this.timeLab.node.active = isShowLab ? true : false
        this.boxSp.spriteFrame = he.load.get('item', cc.SpriteAtlas, 'plist').getSpriteFrame(`${name}`)
        this.timeLab.string = `${util.sceTostrSec(GACHATIMEGRP[index] * 60)}`
    },

    changeName(index) {
        let name
        switch (index) {
            case 1:
                name = '91001'
                break
            case 2:
                name = '91002'
                break
            case 3:
                name = '91003'
                break
            case 4:
                name = '91004'
                break
            case 5:
                name = '91005'
                break
        }
        return name
    },


    clickServer() {
        if (this.canClick) {

        }
    },



});
